//
//  ViewController2.m
//  10504ImageHop
//
//  Created by student on 16/2/19.
//  Copyright © 2016年 niit. All rights reserved.
//

#import "ViewController2.h"

@interface ViewController2 ()
@property (weak, nonatomic) IBOutlet UIButton *btn;
@property (weak, nonatomic) IBOutlet UIImageView *imageView;

@end

@implementation ViewController2

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    NSMutableArray *mArr=[[NSMutableArray alloc]init];
    
    for (int i =1; i<=20; i++) {
        NSString *picName=[NSString stringWithFormat:@"frame-%i",i];
        UIImage *image=[UIImage imageNamed:picName];
        [mArr addObject:image];
    }
    self.imageView.animationImages=mArr;
    self.imageView.animationDuration = 2;
     [self.btn setTitle:@"跳" forState:UIControlStateNormal];
    
    
}
- (IBAction)btnPressed:(id)sender {
    if (self.imageView.isAnimating) {
        [self.imageView stopAnimating];
        [self.btn setTitle:@"跳" forState:UIControlStateNormal];
    }
    else
    {
        [self.imageView startAnimating];
        [self.btn setTitle:@"停" forState:UIControlStateNormal];
    }
}
- (IBAction)slideChanged:(UISlider *)sender {
    self.imageView.animationDuration=2-sender.value;
    if (self.imageView.isAnimating) {
        [self.imageView startAnimating];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
